﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Net;
using Business;
using Common;
//using YiCai.PayService;
using JieBao.PayService;

namespace PayService
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }
        //亿彩
        Thread YCtreRemoteMaintainCookie, YCtreMonitorPay;

        //捷豹
        Thread JBtreRemoteMaintainCookie, JBtreMonitorPay,JBtreMonitorPay2, JBtreMonitorPay3, JBtreMonitorPay4;

        /// <summary>
        /// 启动函数
        /// </summary>
        /// <param name="args"></param>
        protected override void OnStart(string[] args)
        {
            //亿彩
            //YCtreRemoteMaintainCookie = new Thread(new ThreadStart(YCRemoteMaintainCookie));
            //YCtreRemoteMaintainCookie.Start();

            //YCtreMonitorPay = new Thread(new ThreadStart(YCMonitorPay));
            //YCtreMonitorPay.Start();

            //捷豹
            //JBtreRemoteMaintainCookie = new Thread(new ThreadStart(JBRemoteMaintainCookie));
            //JBtreRemoteMaintainCookie.Start();

            JBtreMonitorPay = new Thread(new ThreadStart(JBMonitorPay));
            JBtreMonitorPay.Start();
            //JBtreMonitorPay2 = new Thread(new ThreadStart(JBMonitorPay2));
            //JBtreMonitorPay2.Start();
            //JBtreMonitorPay3 = new Thread(new ThreadStart(JBMonitorPay3));
            //JBtreMonitorPay3.Start();
            //JBtreMonitorPay4 = new Thread(new ThreadStart(JBMonitorPay4));
            //JBtreMonitorPay4.Start();
            LogHelper.Info("正在执行版本号1.0  ");
        }

        /// <summary>
        /// 结束时执行函数
        /// </summary>
        protected override void OnStop()
        {
            try
            {
                //亿彩
                //if (YCtreRemoteMaintainCookie.ThreadState == System.Threading.ThreadState.Running) YCtreRemoteMaintainCookie.Abort();
                //if (YCtreMonitorPay.ThreadState == System.Threading.ThreadState.Running) YCtreMonitorPay.Abort();

                //捷豹
                if (JBtreRemoteMaintainCookie.ThreadState == System.Threading.ThreadState.Running) JBtreRemoteMaintainCookie.Abort();
                //if (JBtreMonitorPay.ThreadState == System.Threading.ThreadState.Running) JBtreMonitorPay.Abort();
                //if (JBtreMonitorPay2.ThreadState == System.Threading.ThreadState.Running) JBtreMonitorPay2.Abort();
                //if (JBtreMonitorPay3.ThreadState == System.Threading.ThreadState.Running) JBtreMonitorPay3.Abort();
                //if (JBtreMonitorPay4.ThreadState == System.Threading.ThreadState.Running) JBtreMonitorPay4.Abort();
            }
            catch (Exception ex)
            {
                LogHelper.Error("错误："+ ex.Message);
            }
        } 
        
        #region 亿彩 
        public void YCMonitorPay()
        {
            //new YiCaiHelper().MonitorPay();
        }
        public void YCRemoteMaintainCookie()
        {
           // new YiCaiHelper().RemoteMaintainCookie();
        }
        #endregion

        #region 捷豹-至尊
        //null 定时刷新cookie
        public void JBRemoteMaintainCookie()
        {
            new JieBaoHelper().RemoteMaintainCookie();
        }
        //监控支付订单
        public void JBMonitorPay()
        {
            //new JieBaoHelper().MonitorPay(1);
            TimeSpan interval = new TimeSpan(0, 0, 5);
            while (true)
            {
                LogHelper.Debug("111");
            }
        }
        //public void JBMonitorPay2()
        //{
        //    new JieBaoHelper().MonitorPay(2);
        //}
        //public void JBMonitorPay3()
        //{
        //    new JieBaoHelper().MonitorPay(3);
        //}
        //public void JBMonitorPay4()
        //{
        //    new JieBaoHelper().MonitorPay(4);
        //}
        #endregion
    }
}
